package com.ftx.controller.ms;

import java.util.*;

/**
 * Created by fengtingxin on 2021/4/4 10:14 上午
 */
public class MsTest {

    public static void main(String[] args) {

//        printSub("aabc");
        System.out.println(xiaomei());
    }

    /**
     * 打印包含空格的子字符串
     */
    public static void printSub(String str){
        char[] chars = str.toCharArray();
        Set<String> result = new HashSet<>();

        String temp = null;
        String temp1 = null;
        for (int i= 0; i < chars.length; i++){
            result.add(String.valueOf(chars[i]));
            result.add(String.valueOf(" " + chars[i]));
            for (int j = i+1; j< chars.length; j++){
                temp = str.substring(i,j);
                if (!result.contains(temp)){
                    result.add(temp);
                }

                temp1 = " "+temp;
                if (!result.contains(temp1)){
                    result.add(temp1);
                }
            }
        }

        System.out.println(result.size());
    }

    public static void qiedao(){
        Scanner input=new Scanner(System.in);

        int n = input.nextInt(); //表示切了几刀
        int[][] array = new int[n][2];
        for (int i =0; i< n;i++){
            array[i][0] = input.nextInt(); //横着切
            array[i][1] = input.nextInt(); //竖着切
        }



    }


    /**
     * 小美的不高兴度
     */
    public static int xiaomei(){
        Scanner input=new Scanner(System.in);
        int n = input.nextInt(); //n
        int k = input.nextInt(); //k
        int[] array = new int[n];
        for (int i =0; i< n;i++){
            array[i] = input.nextInt(); //输入序列
        }
        System.out.println(array);
        String temp = null;
        String key = String.valueOf(k);
        int j = 0;
        int z = 0;
        int result = 0;
        for (int i = 0; i < n; i++){
            z = 0;
            j = 0;
            temp = qiuyinzi(array[i]); //求每个数的因子字符串
            System.out.println(temp);
            //看看key是否匹配
            while(j < temp.length() && z < key.length()){
                if (temp.charAt(j) == key.charAt(z)){
                    j++;
                    z++;
                } else {
                    j++;
                }
            }
            if (z == key.length()){
                result++;
            }
        }
        return result;

    }
    /**
     * 求某个数的因子字符串
     */
    public static String qiuyinzi(int num){
        StringBuffer buffer = new StringBuffer("1");
        int sqrt = (int) Math.sqrt(num);
        for (int i = 2; i <= sqrt; i++) {
            if (num%i== 0) {
                buffer.append(i);
            }
        }
        return buffer.toString();
    }

    public static int yearDay(){
        int result = 0;
        int year = 0;
        int month = 0;
        int day = 0; //一个月的第几天
        int [] monthList=new int[] {0,31,59,90,120,151,181,212,243,273,304,334};
        result = result + monthList[month];
        result= result +day; /*再加上某天的天数*/
        boolean leap = false;
        if(year%400==0||(year%4==0&&year%100!=0))/*判断是不是闰年*/
            leap= true;
        if(leap && month>2){/*如果是闰年且月份大于 2,总天数应该加一天*/
            result++;
        }
        return  result;
    }


}
